<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="Refresh" @click="handleQuery">刷新</el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="classinfoList">
      <el-table-column label="班级名" align="center" prop="className" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link type="primary" icon="Right" @click="handleView(scope.row)"></el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script setup name="Classinfo" lang="ts">
import { MessageListClass } from '@/apis/system/classinfo'
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import router from '@/router'
import { ClassStore } from '@/stores/class'
const classinfoList = ref([]);
const loading = ref(true);
const classStore = ClassStore()

/** 查询班级信息列表 */
function getList() {
  loading.value = true;
  MessageListClass().then(response => {
    if (response.data.code === 200){
      classinfoList.value = response.data.data
    }else {
      ElMessage({
        message: response.data.msg,
        type: 'error'
      });
    }
    loading.value = false;
  });
}

/** 搜索按钮操作 */
function handleQuery() {
  getList();
}

// 查看按钮操作
function handleView(row: any) {
  classStore.classInfo.OriginClassPath = router.currentRoute.value.path
  classStore.classInfo.classID = row.id
  router.push({ path: '/Class/ClassMembers' })
}

getList();
</script>


<style>

</style>
